In [1]:
print (9 + sum(9 - int(10**(1-1.0/n)) for n in range(2, 22)))
Explanation: The one-digit numbers from 1 to 9 are first powers. Assume that $n \ge 2$.
We wish to count the solutions to $10^{n-1} \le k^n < 10^n$ where $k, n \ge 2$. This equation is equivalent to $10^{1-1/n} \le k \le 9$.